/**
 * @{#} ${ classPre }Mapper.java Created on ${ date }
 *
 * Copyright (c) ${ year } by hiwitech.com software.
 */
package ${packageName}.mapper;

import ${packageName}.model.db.${classPre};
import ${packageName}.model.vo.${classPre}VO;
import ${packageName}.model.request.common.CountQuery;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * @author hiwitech
 * @注意 此类自动生成，不能修改
 * @version 1.0
 */
public interface ${classPre}Mapper extends BaseMapper<${classPre}, ${classPre}VO> {

    /**
     * This method was generated by hiwitech Generator.
     * This method corresponds to the database table ${tableName?lower_case}
     */
    @Select({
            "select",
            "<#list properties as pro><#if pro_index == properties?size-1>`${pro.columnName}`<#else>`${pro.columnName}`,</#if></#list>",
            "from ${tableName?lower_case}",
            "where id = ${r"#{id,jdbcType=BIGINT}"}"
    })
    @Results({
    <#list properties as pro>
        <#if pro.proName == 'id'>
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
        <#elseif pro_index != properties?size-1>
            @Result(column = "${pro.proName}", property = "${pro.proName}", jdbcType = JdbcType.${pro.dataBaseProType}),
        <#else>
            @Result(column = "${pro.proName}", property = "${pro.proName}", jdbcType = JdbcType.${pro.dataBaseProType})
        </#if>
    </#list>
    })
	${classPre} loadById(Long id);

    /**
     * This method was generated by hiwitech Generator.
     * This method corresponds to the database table ${tableName?lower_case}
     */
    @UpdateProvider(type = ${classPre}SqlProvider.class, method = "updateById")
    int updateById(${classPre} ${ firstLowerClassPre });

    /**
     * This method was generated by hiwitech Generator.
     * This method corresponds to the database table ${tableName?lower_case}
     */
    @InsertProvider(type = ${classPre}SqlProvider.class, method = "insert")
    @Options(useGeneratedKeys = true, keyProperty = "id")
	int insert(${classPre} ${ firstLowerClassPre });

    <#if hasArchive>
    /**
     * This method was generated by hiwitech Generator.
     * This method corresponds to the database table ${tableName?lower_case}
     */
    @Update({
            "update ${tableName?lower_case}",
            "set archive = true",
            "where id = ${r"#{id,jdbcType=BIGINT}"}"
    })
    int deleteById(Long id);

    /**
     * This method was generated by hiwitech Generator.
     * This method corresponds to the database table ${tableName?lower_case}
     */
    @Update({
            "update ${tableName?lower_case}",
            "set archive = false",
            "where id = ${r"#{id,jdbcType=BIGINT}"}"
    })
    int undeleteById(Long id);  
    <#else>
    /**
     * This method was generated by hiwitech Generator.
     * This method corresponds to the database table ${tableName?lower_case}
     */
    @Update({
            "delete from ${tableName?lower_case}",
            "where id = ${r"#{id,jdbcType=BIGINT}"}"
    })
    int deleteById(Long id);
    </#if>

    /**
     * This method was generated by hiwitech Generator.
     * This method corresponds to the database table ${tableName?lower_case}
     */
    @SelectProvider(type = ${classPre}SqlProvider.class, method = "countQuery")
    int countQuery(CountQuery countQuery);
}